package org.bite.lesson01;

public class Demo03_Runnable {
    public static void main(String[] args) {
        //创建Runnable实例
        MyRunnable01 myRunnable01 = new MyRunnable01();
        //创建线程
        Thread thread = new Thread(myRunnable01);
        //启动线程，创建PCB，参与CPU调度
        thread.start();
        //主线程的任务
        while(true){
            try{
                Thread.sleep(1000);
            }catch(InterruptedException e){
                e.printStackTrace();
            }
            System.out.println("main thread...");
        }
    }
}
//单独定义线程的任务对象
class MyRunnable01 implements Runnable {
    @Override
    public void run(){
        while(true){
            try{
                Thread.sleep(1000);
            }catch(InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Welcome to my runnable...");
        }
    }
}